package com.example.videoworks.controller;


import com.example.videoworks.common.CommonException;
import com.example.videoworks.common.Result;
import com.example.videoworks.controller.request.GetListRequest;
import com.example.videoworks.service.IWorkInService;
import com.example.videoworks.service.IWorkService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lily
 * @since 2023-05-11
 */
@RestController
@RequestMapping("/work-in")
public class WorkInController {

    @Autowired
    private IWorkInService workInService;

    @GetMapping(value="/",produces = "application/json")
    @ApiOperation(value = "查询作品中的影视人员")
    @ApiImplicitParam(name = "workId",value = "作品id",required = true,paramType = "query",dataType = "String")
    public Result principalWorkIn(@NotNull @Valid @RequestBody GetListRequest request, @NotNull @RequestParam("workId")String workId) {
        try{
            return Result.success(workInService.getPrincipalInWork(request, workId));
        }catch (CommonException e){
            return Result.result(e.getCommonErrorCode());
        }
    }


}
